package com.qf.web.dao.impl;

import  com.qf.web.dao.UserDao;
import  com.qf.web.pojo.User;
import  com.qf.web.utils.DbUtils1;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class UserDaoImpl implements UserDao {
   QueryRunner queryRunner = new QueryRunner(DbUtils1.getDs());
    @Override
    public User login(User user) {
    String sql = "select * from user where username = ? and password = ?";

    User currentUser = null;

        try {
            currentUser = queryRunner.query(sql, new BeanHandler<>(User.class), user.getUsername(), user.getPassword());
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        return currentUser;
    }
}
